﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.Xml;
using System.Xml.Linq;



namespace WindowsFormsApplication1
{
    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();
        }

        private void btnReadXML_Click(object sender, EventArgs e)
        {
            string xmlPath = AppDomain.CurrentDomain.BaseDirectory + "xmlTest.xml";
            XElement xmlData = XElement.Parse(System.IO.File.ReadAllText(xmlPath));
            var unit_test = from unit in xmlData.Descendants("UNIT")
                            orderby Int32.Parse(unit.Element("CODE").Value)
                            select new { CODE = unit.Element("CODE").Value, UNIT = unit.Element("UNIT").Value };

            List<String> list = new List<string>();
            foreach (var item in unit_test)
            {
                list.Add(item.CODE.ToString());
            }
            cboXML.DataSource = list;
            //bindingSource1.DataSource = unit_test;
            //cboXML.DataSource = bindingSource1;
            //cboXML.DisplayMember = "UNIT";
            //cboXML.ValueMember = "CODE";
        }

        private void btnExit_Click(object sender, EventArgs e)
        {
            Application.Exit();
            this.Dispose();
        }


    }
}
